#!/usr/bin/make -f
# Sample debian/rules that uses debhelper.
# GNU copyright 1997 to 1999 by Joey Hess.

# Uncomment this to turn on verbose mode.
#export DH_VERBOSE=1

configure: configure-stamp
configure-stamp:
	dh_testdir
	
	# Do some autoconf dancing to make portes happy
	if [ -e scripts/config.sub.dist ]; then rm scripts/config.sub; else mv scripts/config.sub scripts/config.sub.dist; fi
	if [ -e scripts/config.guess.dist ]; then rm scripts/config.guess; else mv scripts/config.guess scripts/config.guess.dist; fi
	ln -s /usr/share/misc/config.sub scripts/config.sub
	ln -s /usr/share/misc/config.guess scripts/config.guess
	
	# Add here commands to configure the package.
	./configure --with-sdl --prefix=/usr --mandir=\$${prefix}/share/man --infodir=\$${prefix}/share/info

	touch configure-stamp

build: configure-stamp build-stamp
build-stamp:
	dh_testdir

	# Add here commands to compile the package.
	$(MAKE)
	/usr/bin/docbook-to-man doc/manpage.sgml > sarien.6

	touch build-stamp

clean:
	dh_testdir
	dh_testroot
	rm -f build-stamp configure-stamp

	# Add here commands to clean up after the build process.
	-$(MAKE) distclean
	-rm bin/sarien
	-rm lib/libagi.a
	-rm lib/libsarien.a
	-rm sarien.6
	-rm doc/sarien.1

	# Reverse the autoconf dancing...
	[ -f scripts/config.sub.dist ] && rm scripts/config.sub && mv scripts/config.sub.dist scripts/config.sub || true
	[ -f scripts/config.guess.dist ] && rm scripts/config.guess && mv scripts/config.guess.dist scripts/config.guess || true

	dh_clean

install: build
	dh_testdir
	dh_testroot
	dh_clean -k
	dh_installdirs

	# Add here commands to install the package into debian/sarien.
	#$(MAKE) install prefix=$(CURDIR)/debian/sarien
	install -d debian/sarien/usr/games
	install -d debian/sarien/etc
	install -m 755 bin/sarien debian/sarien/usr/games
	install -m 644 etc/sarien.cfg debian/sarien/etc/sarien.conf

# Build architecture-independent files here.
binary-indep: build install
# We have nothing to do by default.

# Build architecture-dependent files here.
binary-arch: build install
	dh_testdir
	dh_testroot
#	dh_installdebconf	
	dh_installdocs
	dh_installman sarien.6
	dh_installchangelogs 
	dh_link
	dh_strip
	dh_compress
	dh_fixperms
	dh_installdeb
	dh_shlibdeps
	dh_gencontrol
	dh_md5sums
	dh_builddeb

binary: binary-indep binary-arch
.PHONY: build clean binary-indep binary-arch binary install configure
